import * as types from '../../mutation-types/product/index';

const state = {
    productList : [],
    currentPage :1,
    totalCount : 1
};

const mutations = {
	[types.PRODUCT_LIST] (state , {productList}){
		state.productList = productList;
	},
	[types.PRODUCT_LIST_DEL] (state , {index}){
		const list = state.productList.concat([]);
		const arr = [];
		list.forEach((n,i)=>{
			if(index.indexOf(i)<=-1){
				arr.push(n);
			}
		});
		state.productList = arr;
	},
	[types.PRODUCT_LIST_CURRENTPAGE] (state , {currentPage}){
		state.currentPage = currentPage;
	},
	[types.PRODUCT_LIST_TOTALCOUNT] (state , {totalCount}){
		state.totalCount = totalCount;
	},
	[types.PRODUCT_LIST_ADD] (state , preload){
		//state.salesCategoryList.push(preload);
	},

	[types.PRODUCT_LIST_EDIT] (state , preload){
		//state.totalCount = totalCount;
	},

};

export default {
	state ,
	mutations
};
